/**
 * 房间接口
 */

import {
	request
} from "../utils/request"
import {
	getMD5Sign,
	getRandomText
} from "@/utils/util";

export const getRoomType = () => {
	return request({
		url: "/room/type/tree",
		method: "GET",
	})
}

export const getRoomTree = (params = {}) => {
	return request({
		url: "/room/category/page",
		method: "GET",
		data: params,
	})
}

export const getOrderList = (params) => {
	return request({
		url: "/api/room-order/page",
		method: "GET",
		data: params,
	})
}

export const createOrder = (params) => {
	params.random = getRandomText();
	params.sign = getMD5Sign(params, true);
	return request({
		url: "/room-order/createOrder",
		method: "POST",
		data: params,
	})
}

export const syncOrder = (params) => {
	return request({
		url: "/room-order/sync?orderNo=" + params,
		method: "POST",
		// data: params,
	})
}

export const getOrderById = (params) => {
	return request({
		url: "/room-order/getById",
		method: "GET",
		data: params,
	})
}

export const getOrderByOrderNo = (params) => {
	return request({
		url: "/room-order/getByOrderNo",
		method: "GET",
		data: params,
	})
}

export const deleteOrder = (params) => {
	return request({
		url: "/room-order/remove?id=" + params.id,
		method: "POST",
	})
}

export const cancelOrder = (params) => {
	return request({
		url: "/room-order/close?id=" + params,
		method: "POST",
	})
}

export const againPayOrder = (params) => {
	params.random = getRandomText();
	params.sign = getMD5Sign(params, true);
	return request({
		url: "/room-order/again",
		method: "POST",
		data: params,
	})
}

export const addFavorite = (params) => {
	return request({
		url: "/room/favorite/add?roomCategoryId=" + params.roomCategoryId,
		method: "POST",
	})
}

export const getByCategoryId = (params) => {
	return request({
		url: "/room/favorite/getByCategoryId?categoryId=" + params.id,
		method: "GET",
		//data: params,//categoryId=xxx
	})
}

export const deleteFavorite = (params) => {
	return request({
		url: "/room/favorite/remove?id=" + params.id,
		method: "POST",
		//data: params,
	})
}

export const getMyFavoriteList = (params) => {
	return request({
		url: "/room/favorite/page",
		method: "GET",
		data: params,
	})
}

export const refundOrder = (params) => {
	return request({
		url: "/room-order/refund?orderNo=",
		method: "GET",
		data: params,
	})
}

export const getCategoryById = (params) => {
	return request({
		url: "/room/category/getById",
		method: "GET",
		data: params,
	})
}